home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-pyorbit / examples / c-inproc / test-c-inproc.py < prev    next >
Encoding:
Python Source  |  2008-05-01  |  1.3 KB  |  55 lines

  1. import sys
  2. import ORBit
  3.  
  4. sys.path.append('.libs')
  5. ORBit.load_typelib('./TestCall_module')
  6.  
  7. import CORBA, PyORBit, PyORBit__POA
  8. import cTestCall
  9.  
  10. class PyTestCall(PyORBit__POA.TestCall):
  11.     def op1(self, other):
  12.         this = self._this()
  13.         print "  Python impl of TestCall.op1 invoked"
  14.         other.op2(this)
  15.     def op2(self, other):
  16.         print "  Python impl of TestCall.op2 invoked"
  17.         other.op3()
  18.     def op3(self):
  19.         this = self._this()
  20.         print "  Python impl of TestCall.op3 invoked"
  21.  
  22. orb = CORBA.ORB_init(sys.argv)
  23. poa = orb.resolve_initial_references('RootPOA')
  24.  
  25. # create the C objref
  26. c_objref = cTestCall.create_TestCall(orb)
  27.  
  28. # create the python objref
  29. py_servant = PyTestCall()
  30. py_objref = py_servant._this()
  31.  
  32. # create a python servant that delegates to a C object reference :)
  33. py_delegate_servant = PyORBit__POA.TestCall(c_objref)
  34. py_delegate_objref = py_delegate_servant._this()
  35.  
  36. print "Calling py_objref.op1(py_objref)"
  37. py_objref.op1(py_objref)
  38. print
  39.  
  40. print "Calling c_objref.op1(c_objref)"
  41. c_objref.op1(c_objref)
  42. print
  43.  
  44. print "Calling py_objref.op1(c_objref)"
  45. py_objref.op1(c_objref)
  46. print
  47.  
  48. print "Calling c_objref.op1(py_objref)"
  49. c_objref.op1(py_objref)
  50. print
  51.  
  52. print "Calling py_delegate_objref.op1(py_objref)"
  53. py_delegate_objref.op1(py_objref)
  54. print
  55.